Skip to content

probe: IPC3 firmware probe fixes and direct host-ring extraction for i.MX8MP - #11399

Open
ursus161 wants to merge 1 commit into
thesofproject:mainfrom
ursus161:probes-imx8mp
Open

ursus161 wants to merge 1 commit into
thesofproject:mainfrom
ursus161:probes-imx8mp

Conversation

@ursus161

@ursus161 ursus161 commented Nov 4, 2026

Copy link
Copy Markdown

Fixes IPC3 probes on i.MX8MP (Zephyr) and lets probe data reach the host.

  • Look up probe point buffers with COMP_TYPE_ANY. They were never found, so
    every PROBE_POINT_ADD failed with -EINVAL.
  • Zero-initialize the DMA config structs in probe_dma_init().
  • The i.MX host DMA cannot write to Linux RAM. For IPC3 the host now passes
    a coherent buffer address in the PROBE_INIT stream_tag, and the firmware
    memcpy()s packets into it and publishes a byte counter.

Kernel side: thesofproject/linux#6013

Tested on imx8mp-evk with the kernel PR (1 kHz tone extracted fine).

@sofci

sofci commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

reply test this please to run this test once

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The direct-ring path can misinterpret DMA stream IDs as host addresses and overrun small host rings, creating critical memory-corruption risks.

3 open issues
What changed in this PR

This PR repairs IPC3 probe setup and adds direct host-ring extraction for i.MX8MP, paired with the linked Linux probe client.

Changes:

  • Fix probe-buffer lookup and zero-initialize DMA configuration structures.
  • Add direct copies into a host-provided ring with a published byte counter.
  • Enable probes with up to 16 probe points on the i.MX8MP EVK.
File Description
src/​probe/​probe.c Fixes probe setup and adds IPC3 host-ring extraction.
app/​boards/​imx8mp_evk_mimx8ml8_adsp.conf Enables probes and configures the probe-point limit.

Review effort: Balanced

Comment thread src/probe/probe.c Resolved
Comment thread src/probe/probe.c Resolved
Comment thread src/kernel/probe/probe.c Resolved
@lgirdwood

Copy link
Copy Markdown
Member

@ursus161 @bhiregoudar @DINESHKUMARK1 @LongWang100 @dbaluta looks like there is an issue with recent AMD update for IPC3 probes ? My platforms use IPC4 probes so I would recommend the IPC3 probes adopt a similar host interface for tooling reuse.
@ursus161 does reverting the recent ipc3 probes update fix the issue for you or are the other changes needed too ?

@dbaluta

dbaluta commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@lgirdwood, 2 questions as i have to see if we got this correct:

  • so we need to change the IPC3 interface for tooling from sof/tools/probes to match the interface for IPC4?
  • what is the recent AMD change that we need to revert (is this 78b23ad probe: add probe support for AMD ACP7x platform?).

@lgirdwood

Copy link
Copy Markdown
Member

@lgirdwood, 2 questions as i have to see if we got this correct:

  • so we need to change the IPC3 interface for tooling from sof/tools/probes to match the interface for IPC4?

The request is for IPC3 users to align on the host mechanisms for IPC3 config/control of probes, and the recommendation is to make it as close to IPC4 as possible for least effort in tool reuse.

  • what is the recent AMD change that we need to revert (is this 78b23ad probe: add probe support for AMD ACP7x platform?).

Yes. This PR changes part of that change.

@bhiregoudar

Copy link
Copy Markdown

@lgirdwood, 2 questions as i have to see if we got this correct:

  • so we need to change the IPC3 interface for tooling from sof/tools/probes to match the interface for IPC4?

The request is for IPC3 users to align on the host mechanisms for IPC3 config/control of probes, and the recommendation is to make it as close to IPC4 as possible for least effort in tool reuse.

  • what is the recent AMD change that we need to revert (is this 78b23ad probe: add probe support for AMD ACP7x platform?).

Yes. This PR changes part of that change.

We faced issues with finding the probe points with ipc_get_comp_by_id, so we used the ipc_get_buffer_by_id. Our changes are under macro, they won't affect other platforms.
I think IMX is also facing the same issue of not finding probe points with ipc_get_comp_by_id, could try with ipc_get_buffer_by_id to check whether it works or not.

@ursus161

ursus161 commented Nov 4, 2026

Copy link
Copy Markdown
Author

We faced issues with finding the probe points with ipc_get_comp_by_id, so we used the ipc_get_buffer_by_id. Our changes are under macro, they won't affect other platforms. I think IMX is also facing the same issue of not finding probe points with ipc_get_comp_by_id, could try with ipc_get_buffer_by_id to check whether it works or not.

Yes, this is a way we could do it, at first hand I implemented it using ipc_get_comp_dev and it went OK. I am pushing hot fixes for this PR and the kernel one for problems left untreated raised by Copilot.

I have tested the workflow and all went good, we could use a similar model to existing IPC4 implementation for ease for the least effort, but do you see any problems with this implementation?

If yes, please give me a hard time

@ursus161

ursus161 commented Nov 8, 2026

Copy link
Copy Markdown
Author

Hi all,
Could you please review this PR? The kernel side too, please point me in the right direction if something is not right, I'd like to progress on this feature.

Thanks,
Stefan
@dbaluta @lgirdwood @bhiregoudar @kv2019i @plbossart

Comment thread src/kernel/probe/probe.c Resolved
Comment thread src/kernel/probe/probe.c
@@ -51,8 +51,17 @@ LOG_MODULE_REGISTER(probe, CONFIG_SOF_LOG_LEVEL);
#define PROBE_POINT_INVALID 0xFFFFFFFF

#define PROBE_BUFFER_LOCAL_SIZE 8192
/* host buffer layout: u32 write counter in the first bytes, ring data after the header */
#define PROBE_HOST_HDR_SIZE 4096
#define DMA_ELEM_SIZE 32

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the zephyr/drivers/dma have a look at dma_nxp_sof_host_dma.c. This should provide you a way to "DMA" data into RAM seen by Linux.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, switched this to go through nxp_sof_host_dma instead of memcpy'ing myself.

Turns out the real bug was probe_dma_init() never set a dest_address (PROBE_INIT has no host addr field in IPC3), so dma_reload() had nowhere to write to. not that the driver can't reach host RAM. now the kernel passes the ring's bus addr via stream_tag and the driver gets a real destination.

Extraction now does dma_config() to point the block at the next chunk, then the same dma_reload() AMD/Intel use. old probe_host_write() + wrap logic is gone.

Heads up: the driver ignores, or looks a lot like it, reload()'s own args and just replays the last configured block, so this reconfigures every tick (same as host_copy_one_shot() already does in host-zephyr.c). could follow up with a zephyr patch to give it a real cursor so it behaves like an actual host DMA, happy to do that separately if useful.

Testing on the imx8mp-evk shortly, will report back. thanks a lot for the input.

The changes are here for testing: ursus161@d03474a

@ursus161
ursus161 requested a review from dbaluta November 10, 2026 10:21
@lgirdwood

Copy link
Copy Markdown
Member

Hi all, Could you please review this PR? The kernel side too, please point me in the right direction if something is not right, I'd like to progress on this feature.

Thanks, Stefan @dbaluta @lgirdwood @bhiregoudar @kv2019i @plbossart

@ursus161 I'm not using IPC3 for probes, there are differences though with IPC4 probes so it really up to IPC3 user to align on IPC3 based protocol here. I would recommend ping other IPC3 users and keep going. If no other IPC3 users reply than we can probably merge next week.

@lgirdwood

Copy link
Copy Markdown
Member

test this please

IPC3 PROBE_INIT carries no host buffer address: on Intel the kernel
programs the destination into the HDA stream, so the firmware never
needs one.  On i.MX the host DMA (nxp_sof_host_dma) is configured by
the firmware itself and was never given a destination, so the
extraction channel had nowhere to deliver to and dma_reload() never
moved any probe data.

Have the kernel pass the bus address of a coherent host buffer in the
PROBE_INIT stream_tag field.  The buffer is a header page followed by a
ring whose size is a power of two of at least the local probe ring.
Before every transfer point the host DMA block at the bytes about to go
out, at the offset given by the write counter, then let the common
dma_reload() path copy them, exactly as on the other Zephyr-native
platforms.  The transfer size is already clamped at the end of the
local ring and the host ring is a multiple of it, so the transfer never
has to wrap in the host ring either.

The host DMA reports no position, so after each transfer publish the
write counter in the first word of the header page for the kernel to
poll.  Use channel 0 in probe_dma_init() under PROBE_HOST_RING, since
stream_tag carries an address there, not a channel index; every other
IPC3 platform (e.g. AMD ACP, MediaTek) keeps its previous channel
selection unchanged.

Also enable CONFIG_PROBE=y and CONFIG_PROBE_POINTS_MAX=16 for the
i.MX8MP EVK ADSP board.

Signed-off-by: Stefan Ghetu <stefan.ghetu@nxp.com>
Comment thread src/kernel/probe/probe.c
@@ -1249,7 +1353,7 @@ __cold int probe_point_add(uint32_t count, const struct probe_point *probe)
#elif CONFIG_AMD_ACP_HOST_DMA_PROBE
dev = ipc_get_buffer_by_id(ipc_get(), buf_id->full_id);
#else

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please try to use AMD path for this?

#elif CONFIG_AMD_ACP_HOST_DMA_PROBE || CONFIG_IMX_HOST_DMAPROBE
....

```.

Replacing ipc_get_comp_by_id by ipc_get_comp_dev might break Intel probes. 

Comment thread src/kernel/probe/probe.c
struct dma_config dma_cfg;
struct dma_block_config dma_block_cfg;
struct dma_config dma_cfg = {0};
struct dma_block_config dma_block_cfg = {0};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bugfix and should be place din a separate patch even you can send this as a separate PR so we can merge it faster.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will send this as a separate PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants